package com.zgh.myexamproject;


import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.zgh.myexamproject.bean.User;
import com.zgh.myexamproject.util.MyDBHelper;
import com.zgh.myexamproject.util.loginInfo;


public class GamerIFActivity extends AppCompatActivity {

    TextView z_nc,z_phone,z_bz,z_sex;
    private MyDBHelper myDBHelper;
    private SQLiteDatabase db;
    String sex = "男";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gamer_inf);
        myDBHelper = new MyDBHelper(this);
        z_nc = findViewById(R.id.z_nc);
        z_phone = findViewById(R.id.z_dh);
        z_bz = findViewById(R.id.z_bz);
        z_sex = findViewById(R.id.z_sex);
        /*db.execSQL("update tb_User set nickname='coach',phone='13020900078',note='5.28下午' where username = ?",new String[]{loginInfo.getUsername()});*/
        /* db.execSQL("delete from tb_User where username = ?",new String[]{loginInfo.getUsername()});*/
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        String gamer = bundle.getString("gamer");
        getUser(gamer);
        db.close();
    }
    public void getUser(String name){
        db = myDBHelper.getReadableDatabase();
        /*db.execSQL("update tb_User set nickname='coach',phone='13020900078',note='5.28下午' where username = ?",new String[]{loginInfo.getUsername()});*/
        /* db.execSQL("delete from tb_User where username = ?",new String[]{loginInfo.getUsername()});*/
        Cursor cursor = db.rawQuery("select * from tb_User where username = ?", new String[]{name});
        int resultCounts = cursor.getCount();
        System.out.println(resultCounts);
        if(cursor.getCount()!=0) {
            cursor.moveToFirst();
            if (cursor.getString(cursor.getColumnIndex("nickname"))!=null)
            z_nc.setText(cursor.getString(cursor.getColumnIndex("nickname")));
            if (cursor.getString(cursor.getColumnIndex("phone"))!=null)
            z_phone.setText(cursor.getString(cursor.getColumnIndex("phone")));
            if (cursor.getString(cursor.getColumnIndex("note"))!=null)
            z_bz.setText(cursor.getString(cursor.getColumnIndex("note")));
            if (cursor.getString(cursor.getColumnIndex("sex"))!=null)
            z_sex.setText(cursor.getString(cursor.getColumnIndex("sex")));
        }
    }

}
